<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>商品分类</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card>
      <el-row>
        <el-col :span="8">
          <el-input placeholder="请输入内容" class="input-with-select">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!-- 表格区域 -->
      <el-table :data="orderList" border stripe>
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column label="订单编号" prop="order_number"></el-table-column>
        <el-table-column label="订单价格" prop="order_price"></el-table-column>
        <el-table-column label="是否付款">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status === 0 " type="success">已付款</el-tag>
            <el-tag v-else type="danger">未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="是否发货" prop="is_send"></el-table-column>
        <el-table-column label="下单时间" width="170">
          <template slot-scope="scope">{{ scope.row.create_time |dateFormat }}</template>
        </el-table-column>
        <el-table-column label="是否付款" widtn="100">
          <el-button @click="edit" size="mini" type="primary" icon="el-icon-edit">编辑</el-button>
          <el-button @click="editTwo" size="mini" type="success" icon="el-icon-location"></el-button>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[5, 10, 30, 40]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        background
        :total="400"
      ></el-pagination>
    </el-card>
    <!-- 编辑对话框 给的布尔值来确定是不是 -->

    <el-dialog title="提示" :visible.sync="editDialogVisible" width="50%">
      <!-- 内容 -->
      <el-form :model="editForm" :rules="editRules" ref="rulesRef" class="demo-ruleForm">
        <el-form-item label="省市 区/县:">
          <!-- 节点选择器 -->
          <el-cascader v-model="cascaderValue" :options="cityData"></el-cascader>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="editDialogVisible= false">确 定</el-button>
      </span>
    </el-dialog>
 <!-- 物流显示的对话框 -->
<el-dialog
  title="提示"
  :visible.sync="previweDialogVisible"
  width="50%"
>
<!-- 内容部分 -->

  <el-timeline :reverse="false">
    <el-timeline-item
      v-for="(activity, index) in previewList "
      :key="index"
      :timestamp="activity.timestamp">
      {{activity.content}}
    </el-timeline-item>
  </el-timeline>

  <span slot="footer" class="dialog-footer">
    <el-button @click="previweDialogVisible= false">取 消</el-button>
    <el-button type="primary" @click="previweDialogVisible = false">确 定</el-button>
  </span>
</el-dialog>

  </div>
</template>
<script>
import cityData from './citydata.js'
export default {
  data() {
    return {
      queryInfo: {
        query: "",
        pagenum: 1,
        pagesize: 10
      },
      orderList: [],
      total: 0,
      editDialogVisible: false,
      previweDialogVisible: false,
      editForm: {},
      editRules: {},
      options: {},
      cascaderValue: [],
      previewList: [],
      cityData:cityData
    };
  },
  created() {
    this.getOrderList();
  },
  methods: {
    async getOrderList() {
      const { data: res } = await this.$http.get("orders", {
        params: this.queryInfo
      });
      console.log(res);

      if (res.meta.status !== 200) return this.$message.error("获取失败");
      this.orderList = res.data.goods;
      this.total = res.data.total;
    },
    handleSizeChange(val) {
      this.queryInfo.pagesize = val;
      this.getOrderList();
    },
    handleCurrentChange(val) {
      this.queryInfo.pagenum = val;
      this.getOrderList();
    },
    edit() {
      this.editDialogVisible = true;
    },
    editTwo() {
      this.previweDialogVisible = true;
    },

    async showPreviewDialog() {
      this.previweDialogVisible = true;
      const { data: res } = await this.$http.get(`/kuaidi/1106975712662`);
      if (res.meta.status !== 200) return this.$message.error("获取数据失败");
      this.previewList = res.data;
    },

    handleChange(){

    }
  }
};
</script>
<style scoped lang="less">
</style>